<?php
// +----------------------------------------------------------------------
// | OneThink [ WE CAN DO IT JUST THINK IT ]
// +----------------------------------------------------------------------
// | Copyright (c) 2013 http://www.onethink.cn All rights reserved.
// +----------------------------------------------------------------------
// | Author: 麦当苗儿 <zuojiazi@vip.qq.com> <http://www.zjzit.cn>
// +----------------------------------------------------------------------

namespace Manage\Controller;

use User\Api\UserApi as UserApi;
/**
 * 用户界面控制器
 * 主要获取首页聚合数据
 */
class MemberController extends ManageController {
	
	public function _initialize(){
		parent::_initialize();
		$this->assign('left_menu','INDEX');
	}

	//显示界面
    public function index(){
    	
    	//判断当前用户是否已经登录
    	if(UID){
    		$this->display();
    	} else {
    		$this->redirect('User/login');
    	}
    	
    }
    
    /**
	* 修改个人用户信息
	* @date: 2015-9-10 14:40
    * @author: 刘炎炎
	* @return:
	*/
    public function changepasswd(){
    	//如果是提交修改密码的信息
    	if(IS_POST){
    		
    		$data = array();
    	   
    	   //获取参数
    	   $password   =   I('post.oldpasswd');
    	   //empty($password) && $this->error('请输入原密码');
    	   $data['password'] = I('post.newpasswd');
    	   //empty($data['password']) && $this->error('请输入新密码');
    	   //$repassword = I('post.confirmpasswd');
    	   //empty($repassword) && $this->error('请输入确认密码');
    	   
    	  // if($data['password'] !== $repassword){
    	   //	    $this->error('您输入的新密码与确认密码不一致');
    	  // }
    	   
    	   if(strlen($data['password']) < 6){
    	   	$this->error('新密码的长度小于6位');
    	   }

    	   $Api    =   new UserApi();
    	   $res    =   $Api->updateInfo(UID, $password, $data);
    	   if($res['status']){
    	   		$this->success('修改密码成功！');
    	   }else{
    	   		$this->error($res['info']);
    	   }
    	   exit;
    	}
    	
    	$this->display();
    }
    
    
    
    
    

}